package com.ruoyi.ms1.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ms1.domain.MS1TargetCategory;
import com.ruoyi.ms1.mapper.MS1TargetCategoryMapper;
import com.ruoyi.ms1.service.IMS1TargetCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 目标类别Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-16
 */
@Service
public class MS1TargetCategoryServiceImpl extends ServiceImpl<MS1TargetCategoryMapper, MS1TargetCategory> implements IMS1TargetCategoryService
{
    @Autowired
    private MS1TargetCategoryMapper targetCategoryMapper;

    /**
     * 查询目标类别
     *
     * @param id 目标类别主键
     * @return 目标类别
     */
    @Override
    public MS1TargetCategory selectTargetCategoryById(Long id)
    {
        return targetCategoryMapper.selectTargetCategoryById(id);
    }

    /**
     * 查询目标类别列表
     *
     * @param targetCategory 目标类别
     * @return 目标类别
     */
    @Override
    public List<MS1TargetCategory> selectTargetCategoryList(MS1TargetCategory targetCategory)
    {
        return targetCategoryMapper.selectTargetCategoryList(targetCategory);
    }

    /**
     * 新增目标类别
     *
     * @param targetCategory 目标类别
     * @return 结果
     */
    @Override
    public int insertTargetCategory(MS1TargetCategory targetCategory)
    {
        targetCategory.setCreateTime(DateUtils.getNowDate());
        return targetCategoryMapper.insertTargetCategory(targetCategory);
    }

    /**
     * 修改目标类别
     *
     * @param targetCategory 目标类别
     * @return 结果
     */
    @Override
    public int updateTargetCategory(MS1TargetCategory targetCategory)
    {
        targetCategory.setUpdateTime(DateUtils.getNowDate());
        return targetCategoryMapper.updateTargetCategory(targetCategory);
    }

    /**
     * 批量删除目标类别
     *
     * @param ids 需要删除的目标类别主键
     * @return 结果
     */
    @Override
    public int deleteTargetCategoryByIds(Integer[] ids)
    {
        return targetCategoryMapper.deleteTargetCategoryByIds(ids);
    }

    /**
     * 删除目标类别信息
     *
     * @param id 目标类别主键
     * @return 结果
     */
    @Override
    public int deleteTargetCategoryById(Long id)
    {
        return targetCategoryMapper.deleteTargetCategoryById(id);
    }

    @Override
    public String getNameById(Long id) {
        MS1TargetCategory bean = getById(id);
        if(bean!=null){
            return bean.getCategoryName();
        }
        return null;
    }

}
